package com.qd.common.panda.domain.entity.stroke;

import com.cdqidi.util.page.BaseQuery;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * 行程确认
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class UserStrokeConfirmDTO extends BaseQuery {
    /**
     * 主键
     */
    private String cid;
    /**
     * 行程ID
     */
    private String sid;
    /**
     * 用户扫码时间
     */
    private LocalDateTime scanTime;
    /**
     * 方向:1进场 2离场
     */
    private Integer direction;
    /**
     * 方向显示
     */
    private String directionDisplay;
    /**
     * 保安
     */
    private String personId;
    /**
     * 停车场
     */
    private String parkId;
    /**
     * 停车场显示
     */
    private String parkIdDisplay;
    /**
     * 车牌
     */
    private String plateNumber;
    /**
     * 用户唯一标识
     */
    private String userId;
    /**
     * 用户手机号
     */
    private String mobile;
    /**
     * 机构ID
     */
    private String orgId;
    /**
     * 是否确认
     */
    private String confirm;
    /**
     * 是否确认显示
     */
    private String confirmDisplay;
    /**
     * 确认时间
     */
    private LocalDateTime confirmTime;
    /**
     * 停车费总额
     */
    private BigDecimal amount;
    /**
     * 停车费总额显示
     */
    private String amountDisplay;
    /**
     * 停车时长:单位是秒
     */
    private Long parkTime;
    /**
     * 停车时长显示
     */
    private String parkTimeDisplay;
    /**
     * 门岗名称
     */
    private String doorPostName;
    /**
     * 备注
     */
    private String note;
    /**
     * 计费开始时间
     */
    private LocalDateTime billStartTime;
    /**
     * 计费结束时间
     */
    private LocalDateTime billEndTime;
    /**
     * 订单信息,未支付
     */
    private List<UserStoke> noPayList;
    /**
     * 订单信息,支付成功的
     */
    private List<UserStoke> payOkList;
    /**
     * 行程信息
     */
    private UserStrokeDTO userStroke;

    @Override
    public void freeData() {
        this.cid = null;
        this.sid = null;
        this.scanTime = null;
        this.direction = null;
        this.personId = null;
        this.parkId = null;
        this.plateNumber = null;
        this.userId = null;
        this.mobile = null;
        this.orgId = null;
        this.confirm = null;
        this.confirmTime = null;
        this.billStartTime = null;
        this.billEndTime = null;
        this.parkTime = null;
        this.parkTimeDisplay = null;
        this.amount = null;
        this.amountDisplay = null;
        this.doorPostName = null;
        this.note = null;
        Optional.ofNullable(noPayList).ifPresent(List::clear);
        Optional.ofNullable(payOkList).ifPresent(List::clear);
        Optional.ofNullable(userStroke).ifPresent(UserStrokeDTO::freeData);
        super.freeData();
    }

    @Data
    @Accessors(chain = true)
    public static class UserStoke {
        /**
         * 订单ID
         */
        private String orderId;
        /**
         * 停车费总额
         */
        private BigDecimal amount;
        /**
         * 停车费总额显示
         */
        private String amountDisplay;
        /**
         * 停车时长:单位是秒
         */
        private Long parkTime;
        /**
         * 停车时长显示
         */
        private String parkTimeDisplay;
        /**
         * 计费开始时间
         */
        private LocalDateTime billStartTime;
        /**
         * 计费结束时间
         */
        private LocalDateTime billEndTime;

        /**
         * 0预约订单1停车缴费订单2超时补缴费订单3充电订单
         */
        private Integer orderType;

        public void freeData() {
            this.billStartTime = null;
            this.orderId = null;
            this.billEndTime = null;
            this.parkTime = null;
            this.parkTimeDisplay = null;
            this.amount = null;
            this.amountDisplay = null;
            this.orderType = null;
        }
    }
}
